# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_pkgname=flask-babelex
pkgname=python-flask-babelex
pkgver=0.9.4
pkgrel=7
pkgdesc='Adds i18n/l10n support to Flask applications'
url='https://github.com/mrjoes/flask-babelex'
arch=('any')
license=('BSD')
depends=('python' 'python-flask' 'python-babel' 'python-speaklater' 'python-jinja')
makedepends=('python-sphinx' 'python-setuptools')
checkdepends=('python-pytest')
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/mrjoes/flask-babelex/archive/${pkgver}.tar.gz")
sha512sums=('e5591bcb83ca7e7644b1d06e604834369973bfba5050bd6890ad57125731981cda1e893544eea61cf69dca536e5473e2e50b08b36b0c3daee15d66f3815bd986')

prepare() {
  cd ${_pkgname}-${pkgver}
  # The returned time could contain \u202f instead of spaces
  # https://bugs.chromium.org/p/chromium/issues/detail?id=1414292
  # https://chromium.googlesource.com/chromium/src/+/4e30468e9b3563d7b45e7ade7a1256f69e6967d8
  sed -e 's/April 2010 15:46/April 2010, 15:46/' \
      -e 's/12.04.2010 15:46:00/12.04.2010, 15:46:00/' \
      -e $'s/Apr 12, 2010, 1:46:00 PM/Apr 12, 2010, 1:46:00\u202fPM/' \
      -e $'s/Apr 12, 2010, 3:46:00 PM/Apr 12, 2010, 3:46:00\u202fPM/' \
      -e $'s/1:46:00 PM/1:46:00\u202fPM/' \
      -e $'s/3:46:00 PM/3:46:00\u202fPM/' \
      -i tests/tests.py
}

build() {
  cd ${_pkgname}-${pkgver}
  python setup.py build
  sphinx-build -b text docs docs/_build/text
  sphinx-build -b man docs docs/_build/man
}

check() {
  cd ${_pkgname}-${pkgver}
  py.test tests/tests.py
}

package() {
  cd ${_pkgname}-${pkgver}
  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm 644 README -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 docs/_build/text/*.txt -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 docs/_build/man/flaskbabel.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}

# vim: ts=2 sw=2 et:
